package com.lrkj.util;

import java.nio.*;

public class Byte2Float {
    int accum = 0;
    public static double[] asDoubleArray(byte[] input){
        if(null == input ){
            return null;
        }
        DoubleBuffer buffer = ByteBuffer.wrap(input).asDoubleBuffer();
        double[] res = new double[buffer.remaining()];
        buffer.get(res);
        return res;
    }
    public static float[] asFloatArray(byte[] input){
        if(null == input ){
            return null;
        }
        FloatBuffer buffer = ByteBuffer.wrap(input).asFloatBuffer();
        float[] res = new float[buffer.remaining()];
        buffer.get(res);
        return res;
    }
    public static int[] asIntArray(byte[] input){
        if(null == input ){
            return null;
        }
        IntBuffer buffer = ByteBuffer.wrap(input).asIntBuffer();
        int[] res = new int[buffer.remaining()];
        buffer.get(res);
        return res;
    }
    public static long[] asLongArray(byte[] input){
        if(null == input ){
            return null;
        }
        LongBuffer buffer = ByteBuffer.wrap(input).asLongBuffer();
        long[] res = new long[buffer.remaining()];
        buffer.get(res);
        return res;
    }
    public static short[] asShortArray(byte[] input){
        if(null == input ){
            return null;
        }
        ShortBuffer buffer = ByteBuffer.wrap(input).asShortBuffer();
        short[] res = new short[buffer.remaining()];
        buffer.get(res);
        return res;
    }

}
